{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "03_Pandas",
      "provenance": [],
      "collapsed_sections": [],
      "toc_visible": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "RvwFrkzSPbw7",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://practicalai.me\"><img src=\"https://raw.githubusercontent.com/practicalAI/images/master/images/rounded_logo.png\" width=\"100\" align=\"left\" hspace=\"20px\" vspace=\"20px\"></a>\n",
        "\n",
        "<img src=\"https://raw.githubusercontent.com/practicalAI/images/master/images/03_Pandas/pandas.png\" width=\"300\" vspace=\"30px\" align=\"right\">\n",
        "\n",
        "<div align=\"left\">\n",
        "<h1>Pandas</h1>\n",
        "\n",
        "In this notebook, we'll learn the basics of data analysis with the Python Pandas library.\n",
        "</div>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "0aqN-ffaP4t1",
        "colab_type": "text"
      },
      "source": [
        "<table align=\"center\">\n",
        "  <td>\n",
        "<img src=\"https://raw.githubusercontent.com/practicalAI/images/master/images/rounded_logo.png\" width=\"25\"><a target=\"_blank\" href=\"https://practicalai.me\"> View on practicalAI</a>\n",
        "  </td>\n",
        "  <td>\n",
        "<img src=\"https://raw.githubusercontent.com/practicalAI/images/master/images/colab_logo.png\" width=\"25\"><a target=\"_blank\" href=\"https://colab.research.google.com/github/practicalAI/practicalAI/blob/master/notebooks/03_Pandas.ipynb\"> Run in Google Colab</a>\n",
        "  </td>\n",
        "  <td>\n",
        "<img src=\"https://raw.githubusercontent.com/practicalAI/images/master/images/github_logo.png\" width=\"22\"><a target=\"_blank\" href=\"https://github.com/practicalAI/practicalAI/blob/master/notebooks/03_Pandas.ipynb\"> View code on GitHub</a>\n",
        "  </td>\n",
        "</table>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ta6CPC-QT-K_",
        "colab_type": "text"
      },
      "source": [
        "# Set up"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "6nwDfMoNT-Qa",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "import numpy as np\n",
        "import pandas as pd"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "VfKDIcxXT-TJ",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Set seed for reproducability\n",
        "np.random.seed(seed=1234)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "VoMq0eFRvugb",
        "colab_type": "text"
      },
      "source": [
        "# Download data"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qWro5T5qTJJL",
        "colab_type": "text"
      },
      "source": [
        "We're goign to work with the [Titanic dataset](https://www.kaggle.com/c/titanic/data) which has data on the people who embarked the RMS Titanic in 1912 and whether they survived the expedition or not. It's a very rich dataset which makes it very apt for exploratory data analysis with Pandas."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "cdg5wEFcV6qA",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "import urllib"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "6FuyDUTFVY7J",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Upload data from GitHub to notebook's local drive\n",
        "url = 'https://raw.githubusercontent.com/practicalAI/practicalAI/master/data/titanic.csv'\n",
        "response = urllib.request.urlopen(url)\n",
        "html = response.read()\n",
        "with open('titanic.csv', 'wb') as f:\n",
        "    f.write(html)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "TK3wsHCFhldU",
        "colab_type": "code",
        "outputId": "61d97ead-4f4a-44d5-a390-6965b8f8c5f6",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 69
        }
      },
      "source": [
        "# Checking if the data was uploaded\n",
        "!ls -l "
      ],
      "execution_count": 5,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "total 88\n",
            "drwxr-xr-x 1 root root  4096 Aug 27 16:17 sample_data\n",
            "-rw-r--r-- 1 root root 85153 Oct 10 23:46 titanic.csv\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "TL4rwLUSW9hV",
        "colab_type": "text"
      },
      "source": [
        "# Load data"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "4EOXMnGHiLxM",
        "colab_type": "text"
      },
      "source": [
        "Let's load the data from the CSV file into a Pandas dataframe. The `header=0` signfies that the first row (0th index) is a header row which contains the names of each column in our dataset."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ywaEF_0aQ023",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Read from CSV to Pandas DataFrame\n",
        "df = pd.read_csv('titanic.csv', header=0)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "J79FUzZWQ-kx",
        "colab_type": "code",
        "outputId": "ce4fa8db-a01a-4227-f7c5-d6b8411a6051",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 198
        }
      },
      "source": [
        "# First five items\n",
        "df.head()"
      ],
      "execution_count": 7,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>pclass</th>\n",
              "      <th>name</th>\n",
              "      <th>sex</th>\n",
              "      <th>age</th>\n",
              "      <th>sibsp</th>\n",
              "      <th>parch</th>\n",
              "      <th>ticket</th>\n",
              "      <th>fare</th>\n",
              "      <th>cabin</th>\n",
              "      <th>embarked</th>\n",
              "      <th>survived</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1</td>\n",
              "      <td>Allen, Miss. Elisabeth Walton</td>\n",
              "      <td>female</td>\n",
              "      <td>29.0000</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>24160</td>\n",
              "      <td>211.3375</td>\n",
              "      <td>B5</td>\n",
              "      <td>S</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1</td>\n",
              "      <td>Allison, Master. Hudson Trevor</td>\n",
              "      <td>male</td>\n",
              "      <td>0.9167</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>113781</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>C22 C26</td>\n",
              "      <td>S</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>1</td>\n",
              "      <td>Allison, Miss. Helen Loraine</td>\n",
              "      <td>female</td>\n",
              "      <td>2.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>113781</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>C22 C26</td>\n",
              "      <td>S</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>1</td>\n",
              "      <td>Allison, Mr. Hudson Joshua Creighton</td>\n",
              "      <td>male</td>\n",
              "      <td>30.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>113781</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>C22 C26</td>\n",
              "      <td>S</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>1</td>\n",
              "      <td>Allison, Mrs. Hudson J C (Bessie Waldo Daniels)</td>\n",
              "      <td>female</td>\n",
              "      <td>25.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>113781</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>C22 C26</td>\n",
              "      <td>S</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "   pclass                                             name  ... embarked  survived\n",
              "0       1                    Allen, Miss. Elisabeth Walton  ...        S         1\n",
              "1       1                   Allison, Master. Hudson Trevor  ...        S         1\n",
              "2       1                     Allison, Miss. Helen Loraine  ...        S         0\n",
              "3       1             Allison, Mr. Hudson Joshua Creighton  ...        S         0\n",
              "4       1  Allison, Mrs. Hudson J C (Bessie Waldo Daniels)  ...        S         0\n",
              "\n",
              "[5 rows x 11 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 7
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qhYyM3iGRZ8W",
        "colab_type": "text"
      },
      "source": [
        "These are the diferent features: \n",
        "* **pclass**: class of travel\n",
        "* **name**: full name of the passenger\n",
        "* **sex**: gender\n",
        "* **age**: numerical age\n",
        "* **sibsp**: # of siblings/spouse aboard\n",
        "* **parch**: number of parents/child aboard\n",
        "* **ticket**: ticket number\n",
        "* **fare**: cost of the ticket\n",
        "* **cabin**: location of room\n",
        "* **emarked**: port that the passenger embarked at (C - Cherbourg, S - Southampton, Q = Queenstown)\n",
        "* **survived**: survial metric (0 - died, 1 - survived)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "NBx5VP8K_y6N",
        "colab_type": "text"
      },
      "source": [
        "# Exploratory analysis"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "c4_qAEVI0lpe",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "import matplotlib.pyplot as plt"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "z1Dn2ZTHWUKo",
        "colab_type": "text"
      },
      "source": [
        "We can use `.describe()` to extract some standard details about our numerical features. "
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "thR28yTmASRr",
        "colab_type": "code",
        "outputId": "f60a91f6-18d2-4128-a7a1-4e17c74c30e0",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 288
        }
      },
      "source": [
        "# Describe features\n",
        "df.describe()"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>pclass</th>\n",
              "      <th>age</th>\n",
              "      <th>sibsp</th>\n",
              "      <th>parch</th>\n",
              "      <th>fare</th>\n",
              "      <th>survived</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>count</th>\n",
              "      <td>1309.000000</td>\n",
              "      <td>1046.000000</td>\n",
              "      <td>1309.000000</td>\n",
              "      <td>1309.000000</td>\n",
              "      <td>1308.000000</td>\n",
              "      <td>1309.000000</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>mean</th>\n",
              "      <td>2.294882</td>\n",
              "      <td>29.881135</td>\n",
              "      <td>0.498854</td>\n",
              "      <td>0.385027</td>\n",
              "      <td>33.295479</td>\n",
              "      <td>0.381971</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>std</th>\n",
              "      <td>0.837836</td>\n",
              "      <td>14.413500</td>\n",
              "      <td>1.041658</td>\n",
              "      <td>0.865560</td>\n",
              "      <td>51.758668</td>\n",
              "      <td>0.486055</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>min</th>\n",
              "      <td>1.000000</td>\n",
              "      <td>0.166700</td>\n",
              "      <td>0.000000</td>\n",
              "      <td>0.000000</td>\n",
              "      <td>0.000000</td>\n",
              "      <td>0.000000</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>25%</th>\n",
              "      <td>2.000000</td>\n",
              "      <td>21.000000</td>\n",
              "      <td>0.000000</td>\n",
              "      <td>0.000000</td>\n",
              "      <td>7.895800</td>\n",
              "      <td>0.000000</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>50%</th>\n",
              "      <td>3.000000</td>\n",
              "      <td>28.000000</td>\n",
              "      <td>0.000000</td>\n",
              "      <td>0.000000</td>\n",
              "      <td>14.454200</td>\n",
              "      <td>0.000000</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>75%</th>\n",
              "      <td>3.000000</td>\n",
              "      <td>39.000000</td>\n",
              "      <td>1.000000</td>\n",
              "      <td>0.000000</td>\n",
              "      <td>31.275000</td>\n",
              "      <td>1.000000</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>max</th>\n",
              "      <td>3.000000</td>\n",
              "      <td>80.000000</td>\n",
              "      <td>8.000000</td>\n",
              "      <td>9.000000</td>\n",
              "      <td>512.329200</td>\n",
              "      <td>1.000000</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "            pclass          age  ...         fare     survived\n",
              "count  1309.000000  1046.000000  ...  1308.000000  1309.000000\n",
              "mean      2.294882    29.881135  ...    33.295479     0.381971\n",
              "std       0.837836    14.413500  ...    51.758668     0.486055\n",
              "min       1.000000     0.166700  ...     0.000000     0.000000\n",
              "25%       2.000000    21.000000  ...     7.895800     0.000000\n",
              "50%       3.000000    28.000000  ...    14.454200     0.000000\n",
              "75%       3.000000    39.000000  ...    31.275000     1.000000\n",
              "max       3.000000    80.000000  ...   512.329200     1.000000\n",
              "\n",
              "[8 rows x 6 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 32
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "8KXH6dmb0iY6",
        "colab_type": "code",
        "outputId": "5e8833a5-4c69-4931-bf5c-c989bb71b23e",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 280
        }
      },
      "source": [
        "# Correlation matrix\n",
        "plt.matshow(df.corr())\n",
        "continuous_features = df.describe().columns\n",
        "plt.xticks(range(len(continuous_features)), continuous_features, rotation='45')\n",
        "plt.yticks(range(len(continuous_features)), continuous_features, rotation='45')\n",
        "plt.colorbar()\n",
        "plt.show()"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAASIAAAEHCAYAAAAK30szAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJztnXmYXFW1vt8vIUDCEAgBggQFJMAP\nlQvSggGRSSTMEmZBwnQBGWWGyyCCKKKCTKIBIgjIoKhEiQKiCHJBE1HmKQESwhxQZjJ0f78/9i4s\n+ibd1V2npu71Ps95UsPps3dVqr5ae62115JtgiAIGsmARk8gCIIghCgIgoYTQhQEQcMJIQqCoOGE\nEAVB0HBCiIIgaDghREHQYCSp/N/+SAhREDSeUQC23V/FKIQoCBqEEosAd0i6BPqvGC3U6AkEQT9m\ngO3ZktYEHpP0iu1vlMTI/WjbQ1hEQdAgbLfnm6OB3wAnSzo7P9evLKMQoiBoIJL2BC4FLgbGAntJ\nOhf6lxjF0iwIGouAK2w/RlqebQZMziuzE/vL8iwsoiCoEwuwbt4Adivdsf0M8HNgT0n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WfPLlHs4iUgAAAABJRU5ErkJg\ngg==\n",
            "text/plain": [
              "<Figure size 288x288 with 2 Axes>"
            ]
          },
          "metadata": {
            "tags": []
          }
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "oRaXx2KeWgT3",
        "colab_type": "text"
      },
      "source": [
        "We can also use `.hist()` to view the histrogram of values for each feature."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Mn5HqS3XmzJs",
        "colab_type": "code",
        "outputId": "8b60b7e3-0a3d-4359-9a33-42c2b6144b8a",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 286
        }
      },
      "source": [
        "# Histograms\n",
        "df['age'].hist()"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "<matplotlib.axes._subplots.AxesSubplot at 0x7fabd938d198>"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 36
        },
        {
          "output_type": "display_data",
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAEhFJREFUeJzt3X+M3HWdx/Hn+0A57Jr+OHRS2+aW\ny/U0aM9CN4jRXHblTgtcrCaGQIgW5VL/wDu8NDmLl5waQ9JLRE/PO5J6cKByrBzi0RT8gT1W4yWA\nFJEWKkdPVummtP6A6iIxLr7vj/mujqXt7M7Md2f66fORTPb7/cz3O9/X7nz76ne/853ZyEwkSeX6\nvX4HkCTVy6KXpMJZ9JJUOItekgpn0UtS4Sx6SSqcRS9JhbPoJalwFr0kFe7UfgcAOOOMM3J4eLij\ndZ999lkWLVrU20A9YK75Mdf8DGouGNxsJebatWvXjzPzZW0XzMy+39atW5eduueeezpet07mmh9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6LgbcC/3nkff3IVb0msIHm\nf5CvABbxwlO+tThRi77tRywMgIMRsRyg+npooQNExItolvzNmXn7oORqlZnPAPfQ/JV1SUTMvrdj\noZ/TNwBvjYhJYJzm6ZtP9jnTb1RHg2TmIZrnm8+l/8/lfmB/Zt5Xzd9Gs/j7nWvWBcCDmXmwmu93\nrj8HnsjMH2Xmr4Dbae53te9jJ2rRnwgfsbAd2FhNb6R5jnzBREQA1wN7M/Pjg5KryvayiFhSTZ9O\n87WDvTQL/x39yJaZV2fmyswcprk//XdmXtbPTLMiYlFEvHR2muZ55z30+bnMzKeAJyPildXQ+TQ/\nirzv+1jlUn572gb6n+uHwHkR8ZLq3+fsz6v+faxfL5L04IWNC4H/pXlu9+/7nOUWmufcfkXzKOcK\nmud3dwKPA18Hli1wpjfS/NX0YeCh6nZhv3NV2f4U+E6VbQ/wD9X4HwH3A/to/rp9Wp+ez1Fgx6Bk\nqjJ8t7o9Mru/D8hzuRZ4oHou/wtYOiC5FgE/ARa3jA1Cro8A36v2+88Bpy3EPuY7YyWpcCfqqRtJ\n0hxZ9JJUOItekgpn0UtS4Sx6SSqcRS9JhbPoJalwFr0kFe7/AQnbtZFPqZ/PAAAAAElFTkSuQmCC\n",
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ]
          },
          "metadata": {
            "tags": []
          }
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "7illbHR1nLEF",
        "colab_type": "code",
        "outputId": "b07418db-1e69-472a-86be-7985ef8876f4",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        }
      },
      "source": [
        "# Unique values\n",
        "df['embarked'].unique()"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "array(['S', 'C', nan, 'Q'], dtype=object)"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 38
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "WPQ_JS0RXkRc",
        "colab_type": "text"
      },
      "source": [
        "# Filtering"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "BG1IMeV_hrqV",
        "colab_type": "code",
        "outputId": "82003b37-4dbc-47d6-fbb8-9800793f34f7",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 121
        }
      },
      "source": [
        "# Selecting data by feature\n",
        "df['name'].head()"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "0                      Allen, Miss. Elisabeth Walton\n",
              "1                     Allison, Master. Hudson Trevor\n",
              "2                       Allison, Miss. Helen Loraine\n",
              "3               Allison, Mr. Hudson Joshua Creighton\n",
              "4    Allison, Mrs. Hudson J C (Bessie Waldo Daniels)\n",
              "Name: name, dtype: object"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 40
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "wPrRGLDtiZSp",
        "colab_type": "code",
        "outputId": "f28612bb-03f1-42a2-c0fc-9358a58eae7d",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 198
        }
      },
      "source": [
        "# Filtering\n",
        "df[df['sex']=='female'].head() # only the female data appear"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>pclass</th>\n",
              "      <th>name</th>\n",
              "      <th>sex</th>\n",
              "      <th>age</th>\n",
              "      <th>sibsp</th>\n",
              "      <th>parch</th>\n",
              "      <th>ticket</th>\n",
              "      <th>fare</th>\n",
              "      <th>cabin</th>\n",
              "      <th>embarked</th>\n",
              "      <th>survived</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1</td>\n",
              "      <td>Allen, Miss. Elisabeth Walton</td>\n",
              "      <td>female</td>\n",
              "      <td>29.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>24160</td>\n",
              "      <td>211.3375</td>\n",
              "      <td>B5</td>\n",
              "      <td>S</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>1</td>\n",
              "      <td>Allison, Miss. Helen Loraine</td>\n",
              "      <td>female</td>\n",
              "      <td>2.0</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>113781</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>C22 C26</td>\n",
              "      <td>S</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>1</td>\n",
              "      <td>Allison, Mrs. Hudson J C (Bessie Waldo Daniels)</td>\n",
              "      <td>female</td>\n",
              "      <td>25.0</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>113781</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>C22 C26</td>\n",
              "      <td>S</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6</th>\n",
              "      <td>1</td>\n",
              "      <td>Andrews, Miss. Kornelia Theodosia</td>\n",
              "      <td>female</td>\n",
              "      <td>63.0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>13502</td>\n",
              "      <td>77.9583</td>\n",
              "      <td>D7</td>\n",
              "      <td>S</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>8</th>\n",
              "      <td>1</td>\n",
              "      <td>Appleton, Mrs. Edward Dale (Charlotte Lamson)</td>\n",
              "      <td>female</td>\n",
              "      <td>53.0</td>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>11769</td>\n",
              "      <td>51.4792</td>\n",
              "      <td>C101</td>\n",
              "      <td>S</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "   pclass                                             name  ... embarked  survived\n",
              "0       1                    Allen, Miss. Elisabeth Walton  ...        S         1\n",
              "2       1                     Allison, Miss. Helen Loraine  ...        S         0\n",
              "4       1  Allison, Mrs. Hudson J C (Bessie Waldo Daniels)  ...        S         0\n",
              "6       1                Andrews, Miss. Kornelia Theodosia  ...        S         1\n",
              "8       1    Appleton, Mrs. Edward Dale (Charlotte Lamson)  ...        S         1\n",
              "\n",
              "[5 rows x 11 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 41
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "7lYWUAcxXp0Q",
        "colab_type": "text"
      },
      "source": [
        "# Sorting"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "FOuLeYIojMMH",
        "colab_type": "code",
        "outputId": "3398b6f3-ab88-4b9d-f284-2d3043be3c6e",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 198
        }
      },
      "source": [
        "# Sorting\n",
        "df.sort_values('age', ascending=False).head()"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>pclass</th>\n",
              "      <th>name</th>\n",
              "      <th>sex</th>\n",
              "      <th>age</th>\n",
              "      <th>sibsp</th>\n",
              "      <th>parch</th>\n",
              "      <th>ticket</th>\n",
              "      <th>fare</th>\n",
              "      <th>cabin</th>\n",
              "      <th>embarked</th>\n",
              "      <th>survived</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>14</th>\n",
              "      <td>1</td>\n",
              "      <td>Barkworth, Mr. Algernon Henry Wilson</td>\n",
              "      <td>male</td>\n",
              "      <td>80.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>27042</td>\n",
              "      <td>30.0000</td>\n",
              "      <td>A23</td>\n",
              "      <td>S</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>61</th>\n",
              "      <td>1</td>\n",
              "      <td>Cavendish, Mrs. Tyrell William (Julia Florence...</td>\n",
              "      <td>female</td>\n",
              "      <td>76.0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>19877</td>\n",
              "      <td>78.8500</td>\n",
              "      <td>C46</td>\n",
              "      <td>S</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1235</th>\n",
              "      <td>3</td>\n",
              "      <td>Svensson, Mr. Johan</td>\n",
              "      <td>male</td>\n",
              "      <td>74.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>347060</td>\n",
              "      <td>7.7750</td>\n",
              "      <td>NaN</td>\n",
              "      <td>S</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>135</th>\n",
              "      <td>1</td>\n",
              "      <td>Goldschmidt, Mr. George B</td>\n",
              "      <td>male</td>\n",
              "      <td>71.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>PC 17754</td>\n",
              "      <td>34.6542</td>\n",
              "      <td>A5</td>\n",
              "      <td>C</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>9</th>\n",
              "      <td>1</td>\n",
              "      <td>Artagaveytia, Mr. Ramon</td>\n",
              "      <td>male</td>\n",
              "      <td>71.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>PC 17609</td>\n",
              "      <td>49.5042</td>\n",
              "      <td>NaN</td>\n",
              "      <td>C</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "      pclass  ... survived\n",
              "14         1  ...        1\n",
              "61         1  ...        1\n",
              "1235       3  ...        0\n",
              "135        1  ...        0\n",
              "9          1  ...        0\n",
              "\n",
              "[5 rows x 11 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 42
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "VWxbfIZnXrM4",
        "colab_type": "text"
      },
      "source": [
        "# Grouping"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "v0TCbtSMjMO5",
        "colab_type": "code",
        "outputId": "a972f5d3-349f-4481-a9d5-7dc9764fbeb0",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 138
        }
      },
      "source": [
        "# Grouping\n",
        "survived_group = df.groupby('survived')\n",
        "survived_group.mean()"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>pclass</th>\n",
              "      <th>age</th>\n",
              "      <th>sibsp</th>\n",
              "      <th>parch</th>\n",
              "      <th>fare</th>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>survived</th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>2.500618</td>\n",
              "      <td>30.545369</td>\n",
              "      <td>0.521632</td>\n",
              "      <td>0.328801</td>\n",
              "      <td>23.353831</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1.962000</td>\n",
              "      <td>28.918228</td>\n",
              "      <td>0.462000</td>\n",
              "      <td>0.476000</td>\n",
              "      <td>49.361184</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "            pclass        age     sibsp     parch       fare\n",
              "survived                                                    \n",
              "0         2.500618  30.545369  0.521632  0.328801  23.353831\n",
              "1         1.962000  28.918228  0.462000  0.476000  49.361184"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 43
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "mmcNMYhnXsxC",
        "colab_type": "text"
      },
      "source": [
        "# Indexing"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "-XJK5O95a5OF"
      },
      "source": [
        "We cna use `iloc` to get rows or columns at particuluar positions in the dataframe."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "34LmckWDhdSA",
        "colab_type": "code",
        "outputId": "05093610-6001-432e-8201-9e914e5463d1",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 225
        }
      },
      "source": [
        "# Selecting row 0\n",
        "df.iloc[0, :] "
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "pclass                                  1\n",
              "name        Allen, Miss. Elisabeth Walton\n",
              "sex                                female\n",
              "age                                    29\n",
              "sibsp                                   0\n",
              "parch                                   0\n",
              "ticket                              24160\n",
              "fare                              211.338\n",
              "cabin                                  B5\n",
              "embarked                                S\n",
              "survived                                1\n",
              "Name: 0, dtype: object"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 17
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "QrdXeuRdFkXB",
        "colab_type": "code",
        "outputId": "e8d3cef7-7958-4208-c8c1-e595bae56f7f",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        }
      },
      "source": [
        "# Selecting a specific value\n",
        "df.iloc[0, 1]"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "'Allen, Miss. Elisabeth Walton'"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 18
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "uSezrq4vEFYh",
        "colab_type": "text"
      },
      "source": [
        "# Preprocessing"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "F14RY0N7a_25",
        "colab_type": "text"
      },
      "source": [
        "After exploring, we can clean and preprocess our dataset."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "EZ1pCKHIjMUY",
        "colab_type": "code",
        "outputId": "38c60fb4-ae9b-4900-836c-3fd4c263a791",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 198
        }
      },
      "source": [
        "# Rows with at least one NaN value\n",
        "df[pd.isnull(df).any(axis=1)].head()"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>pclass</th>\n",
              "      <th>name</th>\n",
              "      <th>sex</th>\n",
              "      <th>age</th>\n",
              "      <th>sibsp</th>\n",
              "      <th>parch</th>\n",
              "      <th>ticket</th>\n",
              "      <th>fare</th>\n",
              "      <th>cabin</th>\n",
              "      <th>embarked</th>\n",
              "      <th>survived</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>9</th>\n",
              "      <td>1</td>\n",
              "      <td>Artagaveytia, Mr. Ramon</td>\n",
              "      <td>male</td>\n",
              "      <td>71.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>PC 17609</td>\n",
              "      <td>49.5042</td>\n",
              "      <td>NaN</td>\n",
              "      <td>C</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>13</th>\n",
              "      <td>1</td>\n",
              "      <td>Barber, Miss. Ellen \"Nellie\"</td>\n",
              "      <td>female</td>\n",
              "      <td>26.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>19877</td>\n",
              "      <td>78.8500</td>\n",
              "      <td>NaN</td>\n",
              "      <td>S</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>15</th>\n",
              "      <td>1</td>\n",
              "      <td>Baumann, Mr. John D</td>\n",
              "      <td>male</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>PC 17318</td>\n",
              "      <td>25.9250</td>\n",
              "      <td>NaN</td>\n",
              "      <td>S</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>23</th>\n",
              "      <td>1</td>\n",
              "      <td>Bidois, Miss. Rosalie</td>\n",
              "      <td>female</td>\n",
              "      <td>42.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>PC 17757</td>\n",
              "      <td>227.5250</td>\n",
              "      <td>NaN</td>\n",
              "      <td>C</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>25</th>\n",
              "      <td>1</td>\n",
              "      <td>Birnbaum, Mr. Jakob</td>\n",
              "      <td>male</td>\n",
              "      <td>25.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>13905</td>\n",
              "      <td>26.0000</td>\n",
              "      <td>NaN</td>\n",
              "      <td>C</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "    pclass                          name     sex  ...  cabin  embarked  survived\n",
              "9        1       Artagaveytia, Mr. Ramon    male  ...    NaN         C         0\n",
              "13       1  Barber, Miss. Ellen \"Nellie\"  female  ...    NaN         S         1\n",
              "15       1           Baumann, Mr. John D    male  ...    NaN         S         0\n",
              "23       1         Bidois, Miss. Rosalie  female  ...    NaN         C         1\n",
              "25       1           Birnbaum, Mr. Jakob    male  ...    NaN         C         0\n",
              "\n",
              "[5 rows x 11 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 44
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "zUaiFplEkmoB",
        "colab_type": "code",
        "outputId": "607bf2fa-a591-4428-8b7c-0cd69edf3c39",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 198
        }
      },
      "source": [
        "# Drop rows with Nan values\n",
        "df = df.dropna() # removes rows with any NaN values\n",
        "df = df.reset_index() # reset's row indexes in case any rows were dropped\n",
        "df.head()"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>index</th>\n",
              "      <th>pclass</th>\n",
              "      <th>name</th>\n",
              "      <th>sex</th>\n",
              "      <th>age</th>\n",
              "      <th>sibsp</th>\n",
              "      <th>parch</th>\n",
              "      <th>ticket</th>\n",
              "      <th>fare</th>\n",
              "      <th>cabin</th>\n",
              "      <th>embarked</th>\n",
              "      <th>survived</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>Allen, Miss. Elisabeth Walton</td>\n",
              "      <td>female</td>\n",
              "      <td>29.0000</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>24160</td>\n",
              "      <td>211.3375</td>\n",
              "      <td>B5</td>\n",
              "      <td>S</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>Allison, Master. Hudson Trevor</td>\n",
              "      <td>male</td>\n",
              "      <td>0.9167</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>113781</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>C22 C26</td>\n",
              "      <td>S</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>2</td>\n",
              "      <td>1</td>\n",
              "      <td>Allison, Miss. Helen Loraine</td>\n",
              "      <td>female</td>\n",
              "      <td>2.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>113781</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>C22 C26</td>\n",
              "      <td>S</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>3</td>\n",
              "      <td>1</td>\n",
              "      <td>Allison, Mr. Hudson Joshua Creighton</td>\n",
              "      <td>male</td>\n",
              "      <td>30.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>113781</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>C22 C26</td>\n",
              "      <td>S</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>4</td>\n",
              "      <td>1</td>\n",
              "      <td>Allison, Mrs. Hudson J C (Bessie Waldo Daniels)</td>\n",
              "      <td>female</td>\n",
              "      <td>25.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>113781</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>C22 C26</td>\n",
              "      <td>S</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "   index  pclass  ... embarked survived\n",
              "0      0       1  ...        S        1\n",
              "1      1       1  ...        S        1\n",
              "2      2       1  ...        S        0\n",
              "3      3       1  ...        S        0\n",
              "4      4       1  ...        S        0\n",
              "\n",
              "[5 rows x 12 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 45
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ubujZv_8qG-d",
        "colab_type": "code",
        "outputId": "8cbef6fe-9eea-442d-b168-32aa4d5010c7",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 198
        }
      },
      "source": [
        "# Dropping multiple columns\n",
        "df = df.drop(['name', 'cabin', 'ticket'], axis=1) # we won't use text features for our initial basic models\n",
        "df.head()"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>index</th>\n",
              "      <th>pclass</th>\n",
              "      <th>sex</th>\n",
              "      <th>age</th>\n",
              "      <th>sibsp</th>\n",
              "      <th>parch</th>\n",
              "      <th>fare</th>\n",
              "      <th>embarked</th>\n",
              "      <th>survived</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>female</td>\n",
              "      <td>29.0000</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>211.3375</td>\n",
              "      <td>S</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>male</td>\n",
              "      <td>0.9167</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>S</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>2</td>\n",
              "      <td>1</td>\n",
              "      <td>female</td>\n",
              "      <td>2.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>S</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>3</td>\n",
              "      <td>1</td>\n",
              "      <td>male</td>\n",
              "      <td>30.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>S</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>4</td>\n",
              "      <td>1</td>\n",
              "      <td>female</td>\n",
              "      <td>25.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>S</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "   index  pclass     sex      age  sibsp  parch      fare embarked  survived\n",
              "0      0       1  female  29.0000      0      0  211.3375        S         1\n",
              "1      1       1    male   0.9167      1      2  151.5500        S         1\n",
              "2      2       1  female   2.0000      1      2  151.5500        S         0\n",
              "3      3       1    male  30.0000      1      2  151.5500        S         0\n",
              "4      4       1  female  25.0000      1      2  151.5500        S         0"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 22
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "8m117GcVnon9",
        "colab_type": "code",
        "outputId": "df087bc0-2379-4c7b-a50b-9799136863ab",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 198
        }
      },
      "source": [
        "# Map feature values\n",
        "df['sex'] = df['sex'].map( {'female': 0, 'male': 1} ).astype(int)\n",
        "df['embarked'] = df['embarked'].dropna().map( {'S':0, 'C':1, 'Q':2} ).astype(int)\n",
        "df.head()"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>index</th>\n",
              "      <th>pclass</th>\n",
              "      <th>sex</th>\n",
              "      <th>age</th>\n",
              "      <th>sibsp</th>\n",
              "      <th>parch</th>\n",
              "      <th>fare</th>\n",
              "      <th>embarked</th>\n",
              "      <th>survived</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>29.0000</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>211.3375</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>0.9167</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>2</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>2.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>3</td>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>30.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>4</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>25.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "   index  pclass  sex      age  sibsp  parch      fare  embarked  survived\n",
              "0      0       1    0  29.0000      0      0  211.3375         0         1\n",
              "1      1       1    1   0.9167      1      2  151.5500         0         1\n",
              "2      2       1    0   2.0000      1      2  151.5500         0         0\n",
              "3      3       1    1  30.0000      1      2  151.5500         0         0\n",
              "4      4       1    0  25.0000      1      2  151.5500         0         0"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 23
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ZaVqjpsCEtft",
        "colab_type": "text"
      },
      "source": [
        "# Feature engineering"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Dgb4InI0bcN9",
        "colab_type": "text"
      },
      "source": [
        "We're now going to use feature engineering to create a column called `family_size`. We'll first define a function called `get_family_size` that will determine the family size using the number of parents and siblings. "
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "_FPtk5tpqrDI",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Lambda expressions to create new features\n",
        "def get_family_size(sibsp, parch):\n",
        "    family_size = sibsp + parch\n",
        "    return family_size"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "FCXPqemgbo3H",
        "colab_type": "text"
      },
      "source": [
        "Once we define the function, we can use `lambda` to `apply` that function on each row (using the numbers of siblings and parents in each row to determine the family size for each row)."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "f_Xf97AjlM6s",
        "colab_type": "code",
        "outputId": "988d2f94-f0e0-4f61-8394-c59031820aa2",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 198
        }
      },
      "source": [
        "df[\"family_size\"] = df[[\"sibsp\", \"parch\"]].apply(lambda x: get_family_size(x[\"sibsp\"], x[\"parch\"]), axis=1)\n",
        "df.head()"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>index</th>\n",
              "      <th>pclass</th>\n",
              "      <th>sex</th>\n",
              "      <th>age</th>\n",
              "      <th>sibsp</th>\n",
              "      <th>parch</th>\n",
              "      <th>fare</th>\n",
              "      <th>embarked</th>\n",
              "      <th>survived</th>\n",
              "      <th>family_size</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>29.0000</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>211.3375</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>0.9167</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>3</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>2</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>2.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>3</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>3</td>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>30.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>3</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>4</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>25.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>3</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "   index  pclass  sex      age  ...      fare  embarked  survived  family_size\n",
              "0      0       1    0  29.0000  ...  211.3375         0         1            0\n",
              "1      1       1    1   0.9167  ...  151.5500         0         1            3\n",
              "2      2       1    0   2.0000  ...  151.5500         0         0            3\n",
              "3      3       1    1  30.0000  ...  151.5500         0         0            3\n",
              "4      4       1    0  25.0000  ...  151.5500         0         0            3\n",
              "\n",
              "[5 rows x 10 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 25
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "JK3FqfjnpSNi",
        "colab_type": "code",
        "outputId": "2e5427a0-cc28-4a4c-dac7-0c0506ba980c",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 198
        }
      },
      "source": [
        "# Reorganize headers\n",
        "df = df[['pclass', 'sex', 'age', 'sibsp', 'parch', 'family_size', 'fare', 'embarked', 'survived']]\n",
        "df.head()"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>pclass</th>\n",
              "      <th>sex</th>\n",
              "      <th>age</th>\n",
              "      <th>sibsp</th>\n",
              "      <th>parch</th>\n",
              "      <th>family_size</th>\n",
              "      <th>fare</th>\n",
              "      <th>embarked</th>\n",
              "      <th>survived</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>29.0000</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>211.3375</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>0.9167</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>3</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>2.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>3</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>30.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>3</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>25.0000</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>3</td>\n",
              "      <td>151.5500</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "   pclass  sex      age  sibsp  ...  family_size      fare  embarked  survived\n",
              "0       1    0  29.0000      0  ...            0  211.3375         0         1\n",
              "1       1    1   0.9167      1  ...            3  151.5500         0         1\n",
              "2       1    0   2.0000      1  ...            3  151.5500         0         0\n",
              "3       1    1  30.0000      1  ...            3  151.5500         0         0\n",
              "4       1    0  25.0000      1  ...            3  151.5500         0         0\n",
              "\n",
              "[5 rows x 9 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 26
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "N_rwgfrFGTne",
        "colab_type": "text"
      },
      "source": [
        "# Save data"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "OExbbyancIk4",
        "colab_type": "text"
      },
      "source": [
        "Finally, let's save our preprocessed data into a new CSV file to use later."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "rNNxA7Vrp2fC",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Saving dataframe to CSV\n",
        "df.to_csv('processed_titanic.csv', index=False)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "gfc7Epp7sgqz",
        "colab_type": "code",
        "outputId": "7ed78fb8-3778-4beb-8a65-d5c26fcf9a59",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 86
        }
      },
      "source": [
        "# See the saved file\n",
        "!ls -l"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "total 96\n",
            "-rw-r--r-- 1 root root  6975 Oct 10 15:39 processed_titanic.csv\n",
            "drwxr-xr-x 1 root root  4096 Aug 27 16:17 sample_data\n",
            "-rw-r--r-- 1 root root 85153 Oct 10 15:38 titanic.csv\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "AHb4byg1LUYS",
        "colab_type": "text"
      },
      "source": [
        "# Additional resources"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "4J_w1KsClf7a",
        "colab_type": "text"
      },
      "source": [
        "* **Pandas reference manual**: There's so much more we can do with Pandas and we'll see even more in later notebooks. But if you're curious, checkout the [Pandas user guide](https://pandas.pydata.org/pandas-docs/stable/user_guide/index.html) for more information. "
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "xr1Vsnq7CLpB",
        "colab_type": "text"
      },
      "source": [
        "---\n",
        "<div align=\"center\">\n",
        "\n",
        "Subscribe to our <a href=\"https://practicalai.me/#newsletter\">newsletter</a> and follow us on social media to get the latest updates!\n",
        "\n",
        "<a class=\"ai-header-badge\" target=\"_blank\" href=\"https://github.com/GokuMohandas/practicalAI\"><img src=\"https://img.shields.io/github/stars/GokuMohandas/practicalAI.svg?style=social&label=Star\"></a>&nbsp;&nbsp;\n",
        "<a class=\"ai-header-badge\" target=\"_blank\" href=\"https://www.linkedin.com/company/practicalai-me\"><img src=\"https://img.shields.io/badge/style--5eba00.svg?label=LinkedIn&logo=linkedin&style=social\"></a>&nbsp;&nbsp;\n",
        "<a class=\"ai-header-badge\" target=\"_blank\" href=\"https://twitter.com/GokuMohandas\"><img src=\"https://img.shields.io/twitter/follow/GokuMohandas.svg?label=Follow&style=social\"></a>&nbsp;&nbsp;\n",
        "\n",
        "</div>"
      ]
    }
  ]
}